package com.ai.flight.ai.repository;

import java.util.List;

import org.springframework.ai.chat.memory.ChatMemoryRepository;
import org.springframework.ai.chat.messages.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @Author: suren@517na.com
 * @CreateTime: 2025-06-02
 * @Description: 航班客服对话记忆持久化
 */

@Component
public class FlightAssistantChatMemoryRepository implements ChatMemoryRepository {

    private static final String MEMORY_KEY = "flight:ai:memory:%s";
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;


    private String getMemoryKey(String conversationId) {
        return  String.format(MEMORY_KEY, conversationId);
    }

    @Override
    public List<String> findConversationIds() {

        return null;
    }

    @Override
    public List<Message> findByConversationId(String conversationId) {
        return null;
    }

    @Override
    public void saveAll(String conversationId, List<Message> messages) {

    }

    @Override
    public void deleteByConversationId(String conversationId) {
        redisTemplate.delete(getMemoryKey(conversationId));
    }
}
